<%-- 
    Document   : nuevoContacto
    Created on : 11-sep-2012, 22:31:35
    Author     : ADMIN
--%>

<%@page import="Entities.Cliente"%>
<%@page import="java.util.Iterator"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="javax.persistence.Persistence"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
                <%try{%>        
        <form id="form1" name="form1" method="post" action="http://localhost:8080/appwebdizucar/nuevoContacto">
            <table width="347" border="0" align="center">
                <tr>
                <td colspan="2">NUEVO CONTACTO</td>
                </tr>
                <tr>
                <td>Cliente:</td>
                <td><select name="cbCliente" id="cbCliente">
                    <%
                        
                        EntityManagerFactory emf=Persistence.createEntityManagerFactory("PU");
                        EntityManager em=emf.createEntityManager();
                        Query result = em.createNamedQuery("Cliente.findAll");
                        String ncliente;
                        int clienteid;
                            java.util.List tcList = result.getResultList();
                            Iterator itr=tcList.iterator();
                            
                            while(itr.hasNext())
                            {
                                Cliente cc=(Cliente)itr.next();
                                ncliente=cc.getNombrecliente();
                                clienteid=cc.getIdcliente();
                                out.println("<option value="+clienteid+">"+ncliente+"</option>");
                            }

                        %>
                </select></td>
                </tr>
                <tr>
                <td>Nombre:</td>
                <td><input type="text" name="txtnombre" id="txtnombre" /></td>
                </tr>
                <tr>
                <td>Apellido:</td>
                <td><input type="text" name="txtContacto2" id="txtapellido" /></td>
                </tr>
                <tr>
                <td>Telefono de Oficiona:</td>
                <td><input type="text" name="txttelofi" id="txttelofi" /></td>
                </tr>
                <tr>
                <td>Celular:</td>
                <td><input type="text" name="txtcel" id="txtcel" /></td>
                </tr>
                <tr>
                <td>Correo Electronico:</td>
                <td><input type="text" name="txtemail" id="txtemail" /></td>
                </tr>
                
                <tr>
                <td>Cargo:</td>
                <td><input type="text" name="txtcargo" id="txtcargo" /></td>
                </tr>
                <tr>
                <td><input type="submit" name="btnok" id="btnok" value="Aceptar" /></td>
                <td><input name="btnok2" type="reset" id="btnok2" value="Cancelar" /></td>
                </tr>
            </table>
            </form>
        <%em.close();emf.close();
        
        }catch(Exception e)
        {
        System.err.println(e.toString()+"DINORA");
        }%>
        
    </body>
</html>
